package com.doctorliang.cheng.shopping.base;


import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by CHENG on 2017/9/26.
 */

public abstract class BaseFragment  extends Fragment {//import android.support.v4.app.Fragment;

    protected Context mcontext;
    /**
     * 0当类被创建的时候调用
     * @param savedInstanceState
     */
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mcontext = getActivity();

    }

    /**
     * 1当View被创建的的时候调用
     * @param inflater
     * @param container
     * @param savedInstanceState
     * @return
     */
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        return super.onCreateView(inflater, container, savedInstanceState);
        //初始化布局，由孩子去实现（抽象方法）
        return initView();
    }

    public abstract View initView();

    /**
     * 2当界面创建完成的时候回调
     * @param savedInstanceState
     */
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initData();
    }

    /**
     * 用来初始化数据，由孩子去重写
     */
    public void initData() {
    }
}
